DXL Script to open multiple modules and do a search and replace

Hi All,

I am trying to create a DXL script that will open multiple modules do modifications to each module (find and replace) and then close all the modules.

To open a module I plan to use the read() function call then do the find and replace on the open module then close it and then open the next module using read()

I will not use the built in DOORS search and replace because that opens the Search and replace dialogue which requires user input, whereas I want the search and replace item to be programmatically inserted before the DXL script is done. I am using a function posted here on the forum to do the search and replace on each object.

Does this sound right?
a.mansoor - Thu Nov 29 19:22:12 EST 2012

Re: DXL Script to open multiple modules and do a search and replace
SystemAdmin - Fri Nov 30 01:45:59 EST 2012

almost. You will need the "edit()" function to open the module in exclusive-edit mode.

Re: DXL Script to open multiple modules and do a search and replace
a.mansoor - Fri Nov 30 09:58:08 EST 2012

SystemAdmin - Fri Nov 30 01:45:59 EST 2012
almost. You will need the "edit()" function to open the module in exclusive-edit mode.

Thanks Mike,

Re: DXL Script to open multiple modules and do a search and replace
kone1 - Thu Jun 27 10:58:13 EDT 2013

Hi, Do you recall where you found that search function you mentioned that doesn't require the search and replace dialogue? Thanks

Re: DXL Script to open multiple modules and do a search and replace
adevicq - Thu Jun 27 12:09:21 EDT 2013

Hi,

I have created something that works on all modules of a project / folder. See attached zip.

It works in two modes: simple find and find / replace. It searches int all kinds of attributes including DXL attributes.

There is an include and a main DXL file. Change the include location in the DXL.

A log file is created in yout "temp" directory.

Tell me if it helps...

Regards,

Alain


Attachments

findAndReplaceAttributes.zip

Re: DXL Script to open multiple modules and do a search and replace
llandale - Thu Jun 27 16:27:26 EDT 2013

SystemAdmin - Fri Nov 30 01:45:59 EST 2012
almost. You will need the "edit()" function to open the module in exclusive-edit mode.

... should routinely [1] open invisibly, [2] do not prompt when someone else has it open, and [3] load the standard view:

  • Module mod = edit(NameModule, false, true, true)
  • if (null mod) then either you lack edit rights or someone else has it opened shared/edit.

-Louie

Re: DXL Script to open multiple modules and do a search and replace
sekrbo - Fri Jun 28 03:21:40 EDT 2013

llandale - Thu Jun 27 16:27:26 EDT 2013

... should routinely [1] open invisibly, [2] do not prompt when someone else has it open, and [3] load the standard view:

  • Module mod = edit(NameModule, false, true, true)
  • if (null mod) then either you lack edit rights or someone else has it opened shared/edit.

-Louie

I was thinking... How about

[1] open in read-only

[2] set a filter attr1 contains string1 (or what ever you're looking for) -> Let DOORS do the work :)

[3] if display set == empty close and take next module

[4] open in edit

[5] if not able to edit log module name to a file to fix later and take next module

[6] for each object in display set replace

[7] save and close

[8] next module

/sekrbo

 

Re: DXL Script to open multiple modules and do a search and replace
llandale - Fri Jun 28 16:20:28 EDT 2013

sekrbo - Fri Jun 28 03:21:40 EDT 2013

I was thinking... How about

[1] open in read-only

[2] set a filter attr1 contains string1 (or what ever you're looking for) -> Let DOORS do the work :)

[3] if display set == empty close and take next module

[4] open in edit

[5] if not able to edit log module name to a file to fix later and take next module

[6] for each object in display set replace

[7] save and close

[8] next module

/sekrbo

 

I don't see the benefit of first opening read.  Buf it you feel the need to report that a module has needed changes but cannot be open edit; then perhaps you can do this:

  • Open Edit
  • if edit failed then open Read
  • set filter
  • if not empty results
    • for each objectin display
      • If isEdit then make the change
      • count the change
    • report count of changes, and whether changes were actually made (isEdit)
    • if (isEdit) save
  • else report no changes needed
  • close

-Louie

Re: DXL Script to open multiple modules and do a search and replace
kone11 - Fri Jun 28 16:58:15 EDT 2013

adevicq - Thu Jun 27 12:09:21 EDT 2013

Hi,

I have created something that works on all modules of a project / folder. See attached zip.

It works in two modes: simple find and find / replace. It searches int all kinds of attributes including DXL attributes.

There is an include and a main DXL file. Change the include location in the DXL.

A log file is created in yout "temp" directory.

Tell me if it helps...

Regards,

Alain

Thanks for the reply adevicq, however your code is really hard for me to understand because there are little to no comments.  Do you hapen to know 

when Object o = object(5) instead of searching for the fifth element down.. how to make that search for a particular string of text? for example

In the ID column, i have:

Blue_shoe

Red_shoe

Green_shoe

if i use the function Object o = object 2) then I will receive the output of Red_shoe.. what I am looking to do however is to search for the text Red_shoe.. so I assummed something like Object o = object ("Red_shoe") but that doesn't work.. Anyone have any ideas? Thanks so much

Re: DXL Script to open multiple modules and do a search and replace
adevicq - Mon Jul 01 03:28:19 EDT 2013

kone11 - Fri Jun 28 16:58:15 EDT 2013

Thanks for the reply adevicq, however your code is really hard for me to understand because there are little to no comments.  Do you hapen to know 

when Object o = object(5) instead of searching for the fifth element down.. how to make that search for a particular string of text? for example

In the ID column, i have:

Blue_shoe

Red_shoe

Green_shoe

if i use the function Object o = object 2) then I will receive the output of Red_shoe.. what I am looking to do however is to search for the text Red_shoe.. so I assummed something like Object o = object ("Red_shoe") but that doesn't work.. Anyone have any ideas? Thanks so much

Hi

I agree: there may be more comments... I can add some if needed.

FWI, object(i) will return the object wich identifier (number) is "i". therefore, object(5) returns object #5 according to the ids given by DOORS.

Regards

Re: DXL Script to open multiple modules and do a search and replace
llandale - Tue Jul 02 13:17:00 EDT 2013

adevicq - Mon Jul 01 03:28:19 EDT 2013

Hi

I agree: there may be more comments... I can add some if needed.

FWI, object(i) will return the object wich identifier (number) is "i". therefore, object(5) returns object #5 according to the ids given by DOORS.

Regards

Object o = object(i)  ... so long as that object is accepted in the current view.